﻿using Platformer_Example.Controller.Data;
using Transformable_Engine_v2.Engine;
using Transformable_Engine_v2.Engine.GameObjects.Containers;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Platformer_Example.Controller.Character
{
    public abstract class BaseCharacter : BaseGravityAffected
    {
        protected ImageContainer Character;

        protected override bool IsObject
        {
            get { return false; }
        }



        protected BaseCharacter(Team team)
        {
            Character = new ImageContainer();
            AddChildren(Character);
            Team = team;
        }

        public Team Team { get; private set; }
        public static BaseCharacter Create(BaseCharacter character)
        {
            var c = new Container();
            c.AddChildren(character);
            return character;
        }

        public override void Move(TE_Vector2 position)
        {
            Parent.PositionGridBound = position;
        }

        public override void MoveAbsolute(TE_Vector2 position)
        {
            Parent.Position = position;
        }

        public override void AddToAbsolutePosition(TE_Vector2 offset)
        {
            Parent.Position += offset;
        }

        public override TE_Vector2 GetAbsolutePosition()
        {
            return Parent.AbsolutePosition;
        }

        public void Jump(float value)
        {
            GravityVector = new TE_Vector2(0, value*Game.Options.GridSize);
        }
    }
}